<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserCoinTable extends Migration
{
    /**
     * 用户虚拟账户
     */
    public function up(): void
    {
        Schema::create('user_coin', function (Blueprint $table) {
            $table->integer('user_id');
            $table->double('recharge_coin', 10, 1)->default(0.0)->comment('充值账户余额');
            $table->double('income_coin', 10, 1)->default(0.0)->comment('收入账户余额');
            $table->double('total_income_coin', 10, 1)->default(0.0)->comment('累计收入');
            $table->timestamps();
            $table->unique('user_id', 'user_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_coin');
    }
}
